﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.Base;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_ProjectStatuLogController : BaseApiController
    {
        #region DI

        public PB_ProjectStatuLogController(IPB_ProjectStatuLogBusiness pB_ProjectStatuLogBus)
        {
            _pB_ProjectStatuLogBus = pB_ProjectStatuLogBus;
        }

        IPB_ProjectStatuLogBusiness _pB_ProjectStatuLogBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_ProjectStatuLog>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_ProjectStatuLogBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_ProjectStatuLog> GetTheData(IdInputDTO input)
        {
            return await _pB_ProjectStatuLogBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// 获取项目状态字典数据
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<Base_EnumItem>> GetEnumItem()
        {
            var list = await _pB_ProjectStatuLogBus.GetEnumItem();
            return list;
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_ProjectStatuLog data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_ProjectStatuLogBus.AddDataAsync(data);
            }
            else
            {
                await _pB_ProjectStatuLogBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_ProjectStatuLogBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 获取今天没有进行现场进度提交的楼号并推送钉钉消息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PB_ProjectStatuLogMessage> GetProjectMessAge() {
            var list =await _pB_ProjectStatuLogBus.GetProjectMessAge();
            return list;
        }


        /// <summary>
        /// 获取现场进度数据
        /// </summary>
        /// <param name="input">筛选条件</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_ProjectStatuLoDto>> GetPB_ProjectStatuLoDtoListAsync(PageInput<PB_ProjectStatuLogConditionDTO> input) {
            var LIST = await _pB_ProjectStatuLogBus.GetPB_ProjectStatuLoDtoListAsync(input);
            return LIST;
        }
        #endregion
    }
}